"""
    进行办法三的价格得分统计
"""
# 输入厂家名称及报价
prices = {}
scores = {}
score = 0
print('请输入厂家个数：')
n = int(input())

for i in range(n):
    client_name = input("请输入投标厂家简称：")
    price = float(input("请输入投标价格（万元）："))
    prices[client_name] = price

# 根据标的估值判断扣分分值
predict = float(input("请输入标的估值金额（万元）："))
if predict >= 3000:
    score_minus = 1.2
    print("标的估值额在3000万元及以上，每高出1%基准价，扣{}分".format(score_minus))
elif 1000 <= predict < 3000:
    score_minus = 1
    print("标的估值额在1000-3000万元之间，每高出1%基准价，扣{}分".format(score_minus))
elif 500 <= predict < 1000:
    score_minus = 0.8
    print("标的估值额在500-1000万元之间，每高出1%基准价，扣{}分".format(score_minus))
else:
    score_minus = 0.7
    print("标的估值额在500以下，每高出1%基准价，扣{}分".format(score_minus))

# 求基准价
m = sorted(prices.values(), key=(lambda x: x))
print("按报价由低到高排序：", m)
P_min = m[0]

prices_sum = sum(prices.values())
P_mean = prices_sum / n
print("平均价为{}万元".format(P_mean))

base_price = 0.5 * P_mean + 0.5 * P_min
print("基准价为{}万元".format(base_price))


# 根据基准价求对应厂家的分值
for client_name, price in prices.items():
    if price == base_price:
        score_price = 100
    elif price > base_price:
        per = (price - base_price) / base_price * 100  # 高出基准价的百分比
        print(client_name+"的报价高出基准价"+str(per)+"个百分点")
        score = 100 - per * score_minus
    else:
        per = (base_price - price) / base_price * 100  # 低于基准价的百分比
        print(client_name+"的报价低于基准价"+str(per)+"个百分点")
        if per <= 10:
            score = 100 - 0.3 * per
        elif 10 < per <= 20:
            score = 100 - 0.5 * per
        else:
            score = 100 - per
    if score < 60:
        score = 60
    scores[client_name] = score

print("各厂家依据办法三得分为：{}".format(scores))
